using System;
using System.Collections.Generic;
using System.Text;
using BuildingBasicDomain;
using CommonTypes;

namespace BuildingStructuralElements.LoadingCases
{
    class BeamLoadingCase
    {
        FieldWithUndo m_LoadType;
		FieldWithUndo m_LoadApplicationPhase;
        // Object name, Serves as object ID and key, needs to be unique.
        protected FieldWithUndo m_Name;

        // Objects position
        protected FieldWithUndo m_Position;

        /// <summary>
        /// Gets the component Name
        /// </summary>
        public String Name
        {
            get { return (string)m_Name.Value; }
            set {
                //HandleNameSet(value, false); 
                }
        }

        /// <summary>
        /// Gets or sets the component Position
        /// </summary>
        public Vector Position
        {
            get { return (Vector)m_Position.Value; }
            set { m_Position.Value = value; }
        }

		bool m_IsMirror;

		public LOAD_TYPE LoadType
		{
			get { return (LOAD_TYPE)m_LoadType.Value; }
			set	{ m_LoadType.Value = value; }
		}

		public LOAD_APPLICATION_PHASE LoadApplicationPhase
		{
			get { return (LOAD_APPLICATION_PHASE)m_LoadApplicationPhase.Value; }
			set { m_LoadApplicationPhase.Value = value; }
		}

		public bool IsMirror
		{
			get { return m_IsMirror; }
			set { m_IsMirror = value; }
		}

		// References to composite children. All stored in inherited m_Children list.
        /*
		public Composite Concentrated { get { return (Composite)m_Children[0]; } }
		public Composite Distributed  { get { return (Composite)m_Children[1]; } }
		public Composite MomentZ	  { get { return (Composite)m_Children[2]; } }
		public Composite Shrinkage	  { get { return (Composite)m_Children[3]; } }
		public Composite Temperature  { get { return (Composite)m_Children[4]; } }
        */

		/// <summary>
		/// Constructor
		/// </summary>
		public BeamLoadingCase(string name, Vector position) 

		{
            /*
			Add( new Composite( "Concentrated",	new Vector(0, 0, 0), inMediator) );
			Add( new Composite( "Distributed",	new Vector(0, 0, 0), inMediator) );	
			Add( new Composite( "Moment Z",		new Vector(0, 0, 0), inMediator) );
			Add( new Composite( "Shrinkage",	new Vector(0, 0, 0), inMediator) );
			Add( new Composite( "Temperature",	new Vector(0, 0, 0), inMediator) );
            */
			CreateFieldsWithUndo();
            			
			//m_LoadApplicationPhase.OnChange += new FieldWithUndoChangedEventHandler(m_LoadApplicationPhase_Changed);

			m_IsMirror = false;
			m_LoadType.Value = LOAD_TYPE.G;
			m_LoadApplicationPhase.Value = LOAD_APPLICATION_PHASE.BEFORE_CONCRETE_APPLICATION;
		}



		private void CreateFieldsWithUndo()
		{
			m_LoadType				= new FieldWithUndo(this);
			m_LoadApplicationPhase	= new FieldWithUndo(this);
		}

		public void SetLoadTypeAndPhase(LOAD_TYPE val)
		{
			LOAD_APPLICATION_PHASE phase = (LOAD_APPLICATION_PHASE)m_LoadApplicationPhase.Value;
						
			m_LoadType.SetNewValue( val );

			if(val == LOAD_TYPE.G)			{}
			else if(val == LOAD_TYPE.Q)		phase = LOAD_APPLICATION_PHASE.AFTER_CONCRETE_APPLICATION;
			else if(val == LOAD_TYPE.S)		phase = LOAD_APPLICATION_PHASE.AFTER_CONCRETE_APPLICATION;
			else if(val == LOAD_TYPE.Qser)	phase = LOAD_APPLICATION_PHASE.BEFORE_CONCRETE_APPLICATION;
			else if(val == LOAD_TYPE.W)		phase = LOAD_APPLICATION_PHASE.AFTER_CONCRETE_APPLICATION;
			else if(val == LOAD_TYPE.Sn)	phase = LOAD_APPLICATION_PHASE.AFTER_CONCRETE_APPLICATION;
			else if(val == LOAD_TYPE.A)		phase = LOAD_APPLICATION_PHASE.AFTER_CONCRETE_APPLICATION;
			else if(val == LOAD_TYPE.T)		phase = LOAD_APPLICATION_PHASE.AFTER_CONCRETE_APPLICATION;

			m_LoadApplicationPhase.SetNewValue( phase );	
		}

		public void SetLoadApplicationPhase(LOAD_APPLICATION_PHASE val)
		{
			m_LoadApplicationPhase.SetNewValue(val);
		}

    }
}
